import { getOption } from "../index";

// const aepUrl = 'https://aep-app.gizwits.com/';
// const aepUrl = 'https://app-demo1.lease.iotsdk.com/'; // QA
const aepUrl = 'https://backend-demo.lease.iotsdk.com/backend/'; // 后台QA

export function loginRequest(api, data) {
  return new Promise((resolve, reject) => {
    const { appKey } = getOption();
    wx.request({
      url: `${aepUrl}${api}`,
      method: "POST",
      data: {
        appKey: appKey,
        version: "1.0",
        data,
      },
      header: {
        "Content-Type": "application/json",
        Version: "1.0",
        "X-Gizwits-Application-Id": appKey,
      },
      timeout: 5000,
      success: (data) => {
        resolve(data);
        console.log("data", data);
      },
      fail: (err) => {
        reject(data);
      },
    });
  });
}
